﻿using MongoDB.Bson.Serialization.Attributes;
using MongoDB.Bson;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Gds.Model.ConfigModel.GasMeter
{
    public class GasMeterConfig : INotifyPropertyChanged
    {
        [BsonId]
        public ObjectId _Id { get; set; }
        /// <summary>
        /// 序号
        /// </summary>
        public int GasMeterId { get; set; }
        /// <summary>
        /// 控制器地址
        /// </summary>
        public int ControllerAddress { get; set; }
        /// <summary>
        /// 总线号
        /// </summary>
        public int TotalLineNumber { get; set; }
        /// <summary>
        /// 通道号
        /// </summary>
        public int ChannalId { get; set; }
        /// <summary>
        /// 控制器类型
        /// </summary>
        public DataEnum.GasEquipType GasEquipType { get; set; }
        /// <summary>
        /// 气体类型
        /// </summary>
        public DataEnum.Enum_GasType GasType { get; set; }
        /// <summary>
        /// 量程
        /// </summary>
        public string GasRange { get; set; }
        /// <summary>
        /// 起始量程
        /// </summary>
        public double startRange { get; set; }
        /// <summary>
        /// 结束量程
        /// </summary>
        public double endRange { get; set; }
        public double GetEndRange()
        {
            double result = 100;
            if (GasRange.Split('-').Length == 2)
            {
                result = Convert.ToDouble(GasRange.Split('-')[1].ToString());
                endRange = result;
            }
            return result;
        }
        public double GetStartRange()
        {
            double result = 0;
            if (GasRange.Split('-').Length == 2)
            {
                result = Convert.ToDouble(GasRange.Split('-')[0].ToString());
                startRange = result;
            }
            return result;
        }
        /// <summary>
        /// 单位
        /// </summary>
        public string GasUnit { get; set; }
        /// <summary>
        /// 低报
        /// </summary>
        public double LowAlarmPoint { get; set; }
        /// <summary>
        /// 高爆点
        /// </summary>
        public double HighAlarmPoint { get; set; }
        /// <summary>
        /// 分区位置
        /// </summary>
        public string GasMeterAreaLocation { get; set; }
        /// <summary>
        /// 资产编号
        /// </summary>
        public string GasMeterSerialNo { get; set; }
        /// <summary>
        /// 安装位置
        /// </summary>
        public string GasSettingLocation { get; set; }
        /// <summary>
        /// 备注
        /// </summary>
        public string GasMeterRemark { get; set; }
        /// <summary>
        /// 是否屏蔽
        /// </summary>
        public bool IsUseFlag { get; set; }
        /// <summary>
        /// 是否包含子分区
        /// </summary>
        public bool IsContainChildArea { get; set; }
        /// <summary>
        /// 子分区名称 用于处理当前分区探头数量太多 
        /// </summary>
        public string ChildAreaName { get; set; }
        private string _gasMeterMapPath;
        /// <summary>
        /// 探头地图路径
        /// </summary>
        public string GasMeterMapPath
        {
            get { return _gasMeterMapPath; }
            set
            {
                _gasMeterMapPath = value;
                OnPropertyChanged("GasMeterMapPath");
            }
        }
        /// <summary>
        /// position left
        /// </summary>
        public double GasMeterPositionLeft { get; set; }
        /// <summary>
        /// position top
        /// </summary>
        public double GasMeterPositionTop { get; set; }



        public event PropertyChangedEventHandler PropertyChanged;
        public virtual void OnPropertyChanged(string propertyName)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
            }
        }

    }
}
